<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="commontaglib"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<link rel="stylesheet" href="<%=path%>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/cupertino/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/jquery-ui.custom.min.js"></script> 
    <script type="text/javascript" src="<%=path%>/js/i18n/grid.locale-cn.js"></script>    
    <script type="text/javascript" src="<%=path%>/js/jquery.jqGrid.min.js"></script>
	 <script type="text/javascript" src="<%=path%>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
	<style>
html, body {
	margin: 0;			 
	padding: 0;	 
    font-size: 85%;
}
</style>

	 <script type="text/javascript">  
	   
	    $(function(){ 
			    $("#tongji").button(); 
			    $("#excel").button(); 
			    $("#reset").button();
			    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
			    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
			     $( "#zidqysj" ).datepicker($.datepicker.regional[ "zh-CN" ]);
			    $( "#zidqysj1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
			    queryNum();
			    loadTab();
			    
			    $( "#tabs" ).tabs({
				    select: function(event, ui) {
				    
		  		  }	});
	    
			 });
			 
			 
			  function loadTab(){	  
	   
			      $("#myTab").jqGrid({      
			    url:'<%=path%>/cxtj/jytj.action',   
			    datatype: 'json',
			    mtype: 'post',         
			   	colNames:['合同号','企业合同号','出卖人','发货单位','买受人','收货单位','煤种','品种','价格','数量','签约时间','合同状态'],
			   	colModel:[
			   	    {name:'hetbh',index:'hetbh', width:180},		
   		            {name:'hetlrbh',index:'hetlrbh', width:180},
				   	{name:'chumdwmc',index:'chumdwmc', width:150}, 
				   	{name:'fahdwmc',index:'fahdwmc', width:150},  
				   	{name:'maisdwmc',index:'maisdwmc', width:150}, 
				   	{name:'shouhdwmc',index:'shouhdwmc', width:150},  
				   	{name:'meiz',index:'meiz', width:60},  
				   	{name:'pinz',index:'pinz', width:60},  
				   	{name:'jiag',index:'jiag', width:60},    			
			   		{name:'shul',index:'shul', width:60},			   		
   		            {name:'qianysj',index:'qianysj', width:80},	
   		            {name:'htzt',index:'htzt', width:100, sortable:false}	
			   	],
			   
			    jsonReader: {
			           repeatitems : false, 
			           id: 'hetbh'
			         },    
			    width: 1070, 	
			   	rowNum:10,
			   	rowList:[10,20,30],     	
			   	pager: '#pager13',
			   	rownumbers: true,   	 
			    viewrecords: true,
			    sortname :'qianysj',
			    sortorder: 'desc',
	            altRows:true,
	            shrinkToFit:true,
			    loadError: function (r, st, error) {
			    $("#message").html("status is " + r.status+error+st);},
				//caption: "合同列表"	,
				ondblClickRow: function(){
				     var id = $("#myTab").jqGrid('getGridParam', 'selrow');
				      //alert(id);
				      openwindow('<%=path %>/htgl/htcxInfo.action?htbh='+id); 
	               }
			 
			  });
			  
			  //隐藏发货单位、收货单位
			  $("#myTab").jqGrid('hideCol',["fahdwmc"]);
			  $("#myTab").jqGrid('hideCol',["shouhdwmc"]); 
			  //设置高度
			  $("#myTab").jqGrid('setGridHeight','240px');
			  }
		  
			
			// 查询
			function search(){ 
			  var formdata = $("#form1").serialize();  
			  $("#myTab").jqGrid('setGridParam',{url:'<%=path%>/cxtj/jytj.action?'+formdata,mtype:'post',page:1}).trigger("reloadGrid");  
			}
			//重置
			function resetSearch(){
			   $('#list_search  input[type=text]').val('');
			   $('#list_search select').val('-1');
			 }
			 // 导出excel
			function dc_excel(){  
			    
			    form1.action="<%=path%>/cxtj/jytj_excel.action";
				form1.method="post";		
				form1.submit();
			}
			
			
			//打开连接
          function openwindow(url){
				  var sheight = screen.height-30;
				  var swidth = screen.width-1;
				  var winoption ="height="+sheight+"px,width="+ swidth +"px,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=yes,status=yes";
				  var result=window.open(url,"newwindow",winoption);
				  if(result ==1) window.location.reload(); 
				  return result;  
				}
		
		//计算成交金额函数
		function queryNum(){   
			  var formdata = $("#form1").serialize(); 
			  $.post("<%=path%>/cxtj/queryNum.action",formdata,function(data,textStatus)
			  {
			  
			  var json = eval('(' + data + ')');
			
			  var re=/(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
		if (json[0].zongsl !="")
{
			   $("#queryNum").html("价格范围："+json[0].zongjg + "元/吨  总数量："+json[0].zongsl.toString().replace(re,"$1,")+"吨  总金额："+json[0].zongje.toString().replace(re,"$1,")+"元");
			} else
  {$("#queryNum").html("价格范围：0 元/吨  总数量： 0 吨  总金额：0 元");} });
  
               }
			
</script>  

</head>
<body>  
<div id="best1">
<p></p>
<form id="form1" method="post">
<table id="list_search" cellpadding="0" cellspacing="0" border="0"> 
        <tr>
        	<td> 
            	合同编号: 
            </td>
            <td>
            	<input type="text" class="longtextbox" name="bigbean.AA" /> 
            </td>
            <td>
                                            煤种:
            </td>
            <td>
            	<div class="select"><div><s:select name="bigbean.BB" headerKey="-1" headerValue="请选择"  list="mzList" listKey="diccode" listValue="dicname" id="combobox"/></div></div> 
            </td>            
            <td>
                                             品种 :
            </td>
            <td>
            	<div class="select"><div><s:select name="bigbean.CC" headerKey="-1" headerValue="请选择"  list="pzList" listKey="diccode" listValue="dicname" /></div></div>
            </td>
        </tr>
        
        <tr>
        <td>出卖人:</td>
        <td><input type="text" class="longtextbox" name="bigbean.DD" /></td>
        <td>发货单位:</td>
        <td><input type="text" class="longtextbox" name="bigbean.EE" /></td> 
        <td>出省站/营业站:</td>
        <td><input type="text" class="longtextbox" name="bigbean.FF" /></td>
        </tr>
        
        
        <tr> 
        <td>买受人:</td>
        <td><input type="text" class="longtextbox" name="bigbean.GG" /></td>
        <td>收货单位:</td>
        <td><input type="text" class="longtextbox" name="bigbean.HH" /></td>
        <td>到达省/市:</td>
        <td><input type="text" class="longtextbox" name="bigbean.II" /></td>
        </tr>
        
        
        <tr>
        <td>价格:</td>
        <td><input type="text" class="textboxs" name="bigbean.JJ" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" class="textboxs" name="bigbean.KK" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>数量:</td>
        <td><input type="text" class="textboxs" name="bigbean.LL" onKeyUp="this.value=this.value.replace(/\D/g,'');" />
          --
          <input type="text" class="textboxs" name="bigbean.MM" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
        <td>签订日期:</td>
            <td>
            	<input id="datepicker" type="text" class="textboxs" name="bigbean.NN" /> -- <input id="datepicker1" type="text" class="textboxs" name="bigbean.OO" />
            </td>
        </tr>
        
        
        
        <tr>
        <td>合同形式:</td>
        <td><div class="select"><div><s:select name="bigbean.PP" headerKey="-1" headerValue="请选择"  list="htxsList" listKey="diccode" listValue="dicname" /></div></div></td>        
        <td>合同状态:</td>
        <td><div class="select"><div><s:select name="bigbean.QQ" headerKey="-1" headerValue="请选择"  list="htztList" listKey="diccode" listValue="dicname" /></div></div></td>
        <td>隶属行业:</td>
        <td><div class="select"><div><s:select name="bigbean.RR" headerKey="-1" headerValue="请选择"  list="hyList" listKey="diccode" listValue="dicname" /></div></div></td>
        </tr>
        
        
		<tr>
		<td>配送方式:</td>
        <td>
        <select name="bigbean.VV"/>
           <option value="-1">请选择</option>
           <option value="1">提货</option> 
           <option value="2">送货</option> 
        </select>
        </td>
        <td>交易类型:</td>
        <td><div class="select"><div><s:select name="bigbean.SS" headerKey="-1" headerValue="请选择"  list="dongzlxList" listKey="diccode" listValue="dicname" /></div></div></td>        
       <td>录入日期:</td><td><input id="zidqysj" type="text" class="textboxs" name="bigbean.TT" /> -- <input id="zidqysj1" type="text" class="textboxs" name="bigbean.UU" /></td>
        <td></td>
        <td></td>
        </tr>
			
		<tr>
		<td>买受人结算单位:</td>
        <td><input type="text" class="longtextbox" name="bigbean.WW" /></td>
		</tr>		 
		
  </table>
  </form>
  
  <table id="list_search" cellpadding="0" cellspacing="0" border="0">
  <tr>        
        <td style="float:left">
        <input id="excel" type="button" value="导出excel" onclick="dc_excel();">
        </td>
        <td width="80px"></td>
        <td style="float:right">
        <input id="tongji" type="button" value="查询" onclick="queryNum();search();"/>
        <input id="reset" type="button" value="重置" onclick="resetSearch();"/>
        </td>          
        </tr>
  </table>
   <div id="tabs">
      <ul>
            <li id="queryNum" style="float:right; vertical-align: bottom; line-height:33px; "></li>					
	   </ul>
	    
	<div id="#myTab">
	  <p></p>
	  <div style="margin-left:15px">
	  <table id="myTab" class="scroll" cellpadding="0" cellspacing="0" ></table> 
      <div id="pager13" class="scroll"></div>   
      <div id="message" class="scroll"></div>
      </div>
     
   </div> 
    </div>
</div> 
</body>
</html>